package com.hxd.mall.utils.open

import android.view.View

fun View.getCustomizeTag(): String {
    var mInfo = ""
    try {
        if (tag.toString().contains("-")) {
            mInfo = tag.toString().substring(tag.toString().indexOf("-") + 1)
        }
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        return mInfo
    }
}

fun View.getLocalTag(): String {
    var mInfo = ""
    try {
        if (tag.toString().contains("-")) {
            mInfo = tag.toString().substring(0, tag.toString().indexOf("-"))
        }
    } catch (e: Exception) {
        e.printStackTrace()
    } finally {
        return mInfo
    }
}

fun View.setLocalTag(type: String, localTag: String): String {
    var temp = localTag
    if(temp.contains("-") && temp.indexOf("-") != 0){
        temp = temp.substring(temp.indexOf("-"))
    }
    return type + temp
}